<?php

class User extends Zend_Db_Table_Abstract {
    protected $_name = "users";
    private $dbAdapter;

    public function init() {
        $this->dbAdapter = Zend_Db_Table::getDefaultAdapter();
        $this->dbAdapter->setFetchMode(Zend_Db::FETCH_OBJ);
    }

    public function AuthenticateUser($email, $password){
        try{
            $user = $this->dbAdapter->fetchRow($this->select()->where('password=?', MD5($password))
                    ->where('email=?', $email));
            if($user)
                return $user->id;
            else
                return 0;
        } catch (Zend_Exception $e){
            echo "Error message: " . $e->getMessage() . "\n";
            exit;
        }
    }

}

